In many cases, the information collected by HttpWatch consists of collections of items (Pages, Entries, etc.) In these cases, the automation library provides a collection class for each type of item. These collection classes and the types they contain are as follows:
All the collection classes listed above have the following two properties:
In C#, the implementation of the Item property allows individual members of the collection to be accessed in two ways:
For example, the following code fragment steps through the Log object's Entries collection and prints out the URL for each Entry:
Using foreach with Collection Classes |
Copy Code
|
---|---|
// Loop through each Entry object in the Entries collection foreach( HttpWatch.Entry entry in log.Entries ) { // Prints the URL of each entry recorded Console.WriteLine( entry.URL ); } |
And the following example uses the indexing operator to retrieve the first Entry in the Log object's Entries collection:
Accessing Collection Members by Index |
Copy Code
|
---|---|
// Prints the URL of the first entry recorded
Console.WriteLine( log.Entries[0].URL );
|
It is of course possible to use the index operator notation in a C# for statement, instead of using a foreach loop.
Some classes such as Timings and PageEvents do not hold a variable length list of objects. Instead these classes contain a fixed set of named objects. For example, the Timings class has nine properties that return Timing objects representing timings such as the DNS Lookup and Connect timings.